package lcr;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;

public class Test0150 {
}

class Solution0150_1 {
    public List<List<Integer>> decorateRecord(TreeNode root) {
        ArrayList<List<Integer>> ans = new ArrayList<>();
        if (root == null) return ans;
        ArrayDeque<TreeNode> deque = new ArrayDeque<>();
        deque.offer(root);

        while (!deque.isEmpty()){
            ArrayList<Integer> list = new ArrayList<>();
            int size = deque.size();

            for (int i = 0; i < size; i++){
                TreeNode node = deque.poll();
                list.add(node.val);
                if (node.left != null){
                    deque.offer(node.left);
                }
                if (node.right != null){
                    deque.offer(node.right);
                }
            }
            ans.add(list);
        }

        return ans;
    }
}
